from haystack import indexes
from .models import Blog


class BlogIndex(indexes.SearchIndex, indexes.Indexable):
    # 创建索引
    text = indexes.CharField(document=True, use_template=True)

    # 返回模型类
    def get_model(self):
        return Blog

    # 返回查询集
    def index_queryset(self, using=None):
        return self.get_model().objects.all()
